package teamproject.visualization.gui;

import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.vecmath.AxisAngle4f;

/**
 * Creates a TransformGroup object that rotates a Shape3D object in the scene.
 */
public class Rotator implements TransformGroupGenerator {

	private AxisAngle4f axisAngle;
	private TransformGroup tg;

	/**
	 * 
	 * @param axisAngle
	 *            the AxisAngle that specifies the rotation.
	 */
	public Rotator(AxisAngle4f axisAngle) {
		this.axisAngle = axisAngle;

		tg = new TransformGroup();
	}

	@Override
	public TransformGroup getTransformGroup() {
		tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
		Transform3D transform = new Transform3D();
		transform.set(axisAngle);
		tg.setTransform(transform);

		return tg;
	}

}
